package com.dominator.repository;

import com.dominFramework.core.dao.SqlDao;
import com.dominFramework.core.typewrap.Dto;
import com.dominFramework.core.typewrap.Dtos;
import com.dominFramework.core.utils.SystemUtils;
import com.dominator.mybatis.dao.T_game_goodsPO;
import com.dominator.mybatis.dao.T_game_orderDao;
import com.dominator.mybatis.dao.T_user_game_goodsPO;
import com.dominator.utils.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class DaoGameGoods {


    @Autowired
    SqlDao sqlDao;


    /**
     * 获取用户礼品,分页
     *
     * @param dto
     * @return
     */
    public Dto getMyGoodsListPage(Dto dto) {
        Dto newDto = Dtos.newDto();
        if (SystemUtils.isEmpty(dto.getPageLimit())) {
            dto.setPageLimit(10);
        }
        if (SystemUtils.isEmpty(dto.getPageStart())) {
            dto.setPageStart(0);
        }
        List<Dto> list = sqlDao.list("GameGoods.getMyGoodsListPage", dto);
        newDto.put("datas", list);
        newDto.put("pageLimit", dto.getPageLimit());
        newDto.put("pageStart", dto.getPageStart());
        newDto.put("pageTotal", dto.getPageTotal());

        return newDto;
    }

    /**
     * 获取所有可选礼品列表
     * @param
     * @return
     */
    public List<T_game_goodsPO> getGoodsList() {
         return sqlDao.list("GameGoods.getGameGoodsList", null);
    }

    /**
     * 获取用户获得可选礼品列表
     * @param qDto
     * @return
     */
    public List<T_user_game_goodsPO> getUserGoodsList(Dto qDto){
        return sqlDao.list("GameGoods.getUserGameGoodsList", qDto);
    }


}